package com.violence.web.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
@ConfigurationProperties(prefix = "elasticsearch")
public class ElasticsearchConf {
    private static final Logger logger = LoggerFactory.getLogger(ElasticsearchConf.class);


    private String clusterName;
    private String [] clusterNodes;
    private String username;
    private String password;
    private properties properties = new properties();

    public String getClusterName() {
        return clusterName;
    }

    public void setClusterName(String clusterName) {
        this.clusterName = clusterName;
    }

    public String[] getClusterNodes() {
        return clusterNodes;
    }

    public void setClusterNodes(String[] clusterNodes) {
        this.clusterNodes = clusterNodes;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public ElasticsearchConf.properties getProperties() {
        return properties;
    }

    public void setProperties(ElasticsearchConf.properties properties) {
        this.properties = properties;
    }

    class properties {
        /**  超时时间  */
        public  Integer connectTimeOut  ;
        /**  连接超时时间。  */
        public  Integer socketTimeOut  ;
        /**  超时时间  */
        public  Integer connectionRequestTimeOut  ;
        /**  最大连接数。  */
        public  Integer maxConnectTotal ;
        /**  最大路由连接数  */
        public  Integer maxConnectPerRoute;

        public Integer getConnectTimeOut() {
            return connectTimeOut;
        }

        public void setConnectTimeOut(Integer connectTimeOut) {
            this.connectTimeOut = connectTimeOut;
        }

        public Integer getSocketTimeOut() {
            return socketTimeOut;
        }

        public void setSocketTimeOut(Integer socketTimeOut) {
            this.socketTimeOut = socketTimeOut;
        }

        public Integer getConnectionRequestTimeOut() {
            return connectionRequestTimeOut;
        }

        public void setConnectionRequestTimeOut(Integer connectionRequestTimeOut) {
            this.connectionRequestTimeOut = connectionRequestTimeOut;
        }

        public Integer getMaxConnectTotal() {
            return maxConnectTotal;
        }

        public void setMaxConnectTotal(Integer maxConnectTotal) {
            this.maxConnectTotal = maxConnectTotal;
        }

        public Integer getMaxConnectPerRoute() {
            return maxConnectPerRoute;
        }

        public void setMaxConnectPerRoute(Integer maxConnectPerRoute) {
            this.maxConnectPerRoute = maxConnectPerRoute;
        }
    }

    @PostConstruct
    private void init() {
        logger.info("ElasticsearchConf init ...");
    }
}
